rm(list=ls())

pacman::p_load(tidyverse, sf)

rescale01 <- function(x){
  minx <- min(x, na.rm=T)
  maxx <- max(x, na.rm=T)
  return((x-minx)/(maxx - minx))
}

# Figure 1 Map of "Treated" Areas
joined <- read_sf('datasets/mapdata.shp')
plot <- ggplot(data=joined) +
  geom_sf(aes(fill=s_lvl_r, geometry = geometry), size=0.1, color='grey80') +
  theme_map() +
  scale_fill_gradientn(colours=RColorBrewer::brewer.pal(9,"PuBu"),
                       name='Sea Level Rise\nSusceptibility') 

plot
ggsave(plot, width=8, height=6, 
       file='figures/figure1_map.pdf')
